package com.smsc.headend.task.engine.utils;

import cn.hutool.json.JSONUtil;
import com.smsc.headend.module.task.dto.AtomicTask;
import com.smsc.headend.module.task.dto.Task;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class TaskParamUtils {

    public static Map<String, Object> getParameterMap(Task task, AtomicTask atomicTask) {
        Map<String, Object> paramMap = new HashMap<>();
        if (StringUtils.isNotEmpty(task.getParamJson())) {
            paramMap.putAll(JSONUtil.toBean(task.getParamJson(), Map.class));
        }
        if (atomicTask != null && StringUtils.isNotEmpty(atomicTask.getAtomicTaskParam())) {
            paramMap.putAll(JSONUtil.toBean(atomicTask.getAtomicTaskParam(), Map.class));
        }
        return paramMap;
    }
}
